package com.controller;


import com.common.contant.RestResponse;

import com.service.CategoryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * @Author: sijunqiang
 * @Date: 2020/5/16 10:56
 * @Description: 分类的控制层
 */
@Slf4j
@RestController
@RequestMapping(value = "/category")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "商品分类控制层")
public class CategoryController {


    private final CategoryService categoryService;

    @GetMapping(value = "/list")
    public RestResponse queryByParentId(@RequestParam(value = "id", defaultValue = "0") Long pid) {
        log.info("查询分类请求的参数：[{}]", pid);
        return RestResponse.success(categoryService.queryListByParent(pid));
    }

    @GetMapping(value = "of/parent")
    public RestResponse queryCategoryList(@RequestParam(value = "id", defaultValue = "0") Long pid) {
        log.info("查询分类请求的参数：[{}]", pid);
        return RestResponse.success(categoryService.queryListByParent(pid));
    }





}





















